package com.core.image.core;

import java.io.InputStream;

/**
 * describe:
 *
 * @author 库琦
 * @date 2020/01/24
 */
public abstract  class SendPacket<T extends InputStream> extends Packet<T>{
    private boolean isCanceled;
    public boolean isCanceled(){
        return isCanceled;
    }
    public void cancel(){
        isCanceled = true;
    }

    public int available(){
        InputStream stream = open();
        try {
            int available = stream.available();
            if (available < 0){
                return 0;
            }
            return available;
        }catch (Exception e){
            return 0;
        }
    }
}
